app.controller("brandController", function ($scope, $controller,brandService) {

    $controller("baseController",{$scope:$scope});
    //品牌列表展示
    $scope.findAll = function () {
        brandService.findAll().success(
            function (data) {
                $scope.list = data;
            }
        );
    };


    //分页查询
    $scope.findPage = function (page, size) {
        brandService.findPage(page, size).success(
            function (data) {
                $scope.list = data.rows;
                $scope.paginationConf.totalItems = data.total;
            }
        );
    };

    //添加
    $scope.save = function () {
        var object = null;
        if ($scope.entity.id != null) {
            object = brandService.update($scope.entity);
        } else {
            object = brandService.add($scope.entity);
        }
        object.success(
            function (data) {
                if (data.success) {
                    $scope.reloadList();
                } else {
                    alert(data.message);
                }
            }
        );
    };


    //修改回显数据
    $scope.findOne = function (id) {
        brandService.findOne(id).success(
            function (data) {
                $scope.entity = data;
            }
        );
    };




    //删除方法
    $scope.dele = function () {
        brandService.dele($scope.selectIds).success(
            function (data) {
                if (data.success) {
                    $scope.reloadList();
                } else {
                    alert(data.message);
                }
            }
        );
    };

    //模糊查询
    $scope.searchEntity = {};
    $scope.search = function (page, size) {
        brandService.search(page, size, $scope.searchEntity).success(
            function (data) {
                $scope.list = data.rows;
                $scope.paginationConf.totalItems = data.total;
            }
        );
    }
});